home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / datedem.com / DATES.DOC < prev    next >
Encoding:
Text File  |  1989-03-11  |  6.1 KB  |  141 lines

  1.                         DATE Handling routines for C.
  2.  
  3.         Very brief documentation for the dates routines for C.  As the
  4.         source code is included you may check it out or change it as you
  5.         wish.
  6.  
  7.         Handling of date data items is difficult if using strings,
  8.         there are many data entry errors possible as well as the
  9.         comparison of string dates is difficult.  This package stores
  10.         regular (gregorian) dates as longs to keep the comparisons easy.
  11.         Julian dates are stored in a strucutre and therefore are more
  12.         difficult to use.
  13.  
  14.         The DATES type is defined in the dates.h file as well as the
  15.         prototypes for each function expected to be called from the
  16.         outside world.
  17.  
  18.         The package was developed for my own use and is put into the
  19.         Public Domain for any use, as of 11 Mar 1989 by Gerald Rohr the
  20.         author.
  21.  
  22.         The DATE (long) data item has the date stored as YYYYMMDD and
  23.         the date routines handle the format and information about it.
  24.         This makes it easy to compare and sort by DATEs.  The NO_DATE
  25.         define is just a data item of 0L.
  26.  
  27.         The following files should be in the archive which was archived
  28.         with ARC version 5.2:
  29.  
  30.         dates.h         header file for dates.c and user files.
  31.         dates.c         source code for dates.obj
  32.         dates.obj       the small object dates library
  33.         dates.doc       this file
  34.         datedemo.c      The demo program source code.
  35.         datedemo.exe    The compiled demo program
  36.  
  37.         The list of functions and a brief description of each is shown
  38.         below.  There is no printer paging to save space and enable you
  39.         to load the dates.doc file into an editor window as a help file.
  40.         I know it is proper to have each function described on a
  41.         seperate page but this sure saves a lot of space and paper.
  42.  
  43.         char *dtoa(DATE in_date)
  44.         Returns character pointer to the string date in the format
  45.         (MM/DD/YYYY).
  46.  
  47.         int day(DATE in_date)
  48.         Returns an integer which is the day portion of a DATE.
  49.  
  50.         int month(DATE in_date)
  51.         Returns an integer which is the month portion of a DATE.
  52.  
  53.         int year(DATE in_date,int cf)
  54.         Returns an integer which is the year portion of a DATE.  If cf
  55.         (century flag) is true the returned integer will be 4 digits
  56.         wide (ie 1989) if false the returned integer will be the 2 digit
  57.         year only (ie 89).
  58.  
  59.         DATE jul_to_greg(JULDATE *jdt)
  60.         Returns the DATE (long) value of the information in the JULDATE
  61.         structure passed.  Note the value passed to this function is the
  62.         address of the JULDATE structure.
  63.  
  64.         void greg_to_jul(DATE in_date,JULDATE *jdt)
  65.         Converts the Gregorian (DATE) to Julian, As before the address
  66.         of the JULDATE structure you desire the converted Julian date to
  67.         be in is passed to this function.
  68.  
  69.         void prev_day(DATE *dt)
  70.         Subtracts one from DATE variable, The address of the DATE
  71.         variable you wish to be decremented is passed to this function.
  72.  
  73.         void next_day(DATE *dt)
  74.         Adds one to DATE variable,  The address of the DATE variable you
  75.         wish to be incremented is passed to this function.
  76.  
  77.         int valid_date(DATE dt)
  78.         Checks if date is valid, returns the following integers informing
  79.         the caller of the results fo the validation.  NO_DATE will
  80.         return a valid status.
  81.  
  82.         char *month_name(int mon)
  83.         Returns character pointer to full month name, ie January.  The
  84.         returned string is defined as "read only", that is you may read
  85.         (strcpy, etc) the string at the address returned but if you
  86.         write to it, other calls to the function will not return valid
  87.         data.
  88.  
  89.         char *day_name(DATE in_date)
  90.         Returns character pointer to full day of week name, ie
  91.         Wednesday.  The returned string is defined as "read only".
  92.  
  93.         int zeller(DATE dt)
  94.         Returns day of week ( 0-6) from date using the Zeller Congruance
  95.         function.
  96.  
  97.         char *jul_dt_st(JULDATE *jdt)
  98.         Returns character pointer to Julian date string in the format
  99.         YYYY/DDD.
  100.  
  101.         char *full_date_st(DATE in_date)
  102.         Returns character pointer to full date string in the format
  103.         "Wednesday March 11, 1989".  The returned string is defined as
  104.         "read only".
  105.  
  106.         To get a feel for how these functions work, print a listing of
  107.         the datedemo.c program and refer to it when looking at the
  108.         output of the datedemo.exe program when run.
  109.  
  110.         All functions use prototypes which need to be removed if ported
  111.         to a compiler which does not support them (read Unix).  The code
  112.         is very generic and should run under almost any compiler.
  113.  
  114.         In the works are input and output routines to input dates with
  115.         valid date checking as well as incorporating them into the
  116.         windowing functions developed by the Alexandria campus of the
  117.         Northern Virginia Community College, which is also released for
  118.         public use. I have already made many changes to this package and
  119.         as all souce code is included, one can bend it to do what ever
  120.         you wish.  After looking at many other windowing packages, this
  121.         seems to be one of the best to start with and the source code is
  122.         included.
  123.  
  124.         The dates.obj file was created using Turbo C version 2.0 for the
  125.         small model.  To create any other model, in another directory
  126.         enter the following command line information where the x is
  127.         replaced by the model you wish to use:
  128.  
  129.         tcc -c -mx dates.c<return>
  130.  
  131.         Also available in the Public Domain are the following packages:
  132.  
  133.         grstrings   A few string formatters for C.
  134.         tp5wio      A complete windowing I/O package for TP5.
  135.         tp5misc     Part of tp5wio.
  136.  
  137.         Gerald Rohr               Compuserve 70035,1223
  138.         Homogenized Software      Genie      g.rohr
  139.         RR#3
  140.         Anamosa, Iowa 52205
  141.